package cn.doitedu.day02

object T18_MyHashPartitioner {

  def main(args: Array[String]): Unit = {

    val key = "spark"
    //val key = "kafka"
    //val key = "hadoop"
    val numPartitions = 4

    val mod = key.hashCode % numPartitions
    val partition = mod + (if (mod < 0) numPartitions else 0)

    println(partition)

  }

}
